<?php

class Web_Cuenta extends Web_BasePage
{

    public function mainContent()
    {
//        parent::set_title('');
//        parent::add_head_content('<meta name="Keywords" content="" />');
//        parent::add_head_content('<meta name="Description" content="" />');
//        parent::add_head_content('<meta name="robots" content="index, follow, all" />');
//        parent::add_head_content('<meta name="revisit-after" content="7 days" />');
        
        if ($_SESSION['usr'] != true){
            Ey::redirect(WEB_ROOT);
        }

        $error = '';
        $post = '';
        $envio = '';

        if (isset($_SESSION['error'])) {
            $error = $_SESSION['error'];
            unset($_SESSION['error']);
        }
        if (isset($_SESSION['post'])) {
            $post = $_SESSION['post'];
            unset($_SESSION['post']);
        }
        if (isset($_SESSION['envio'])) {
            $envio = $_SESSION['envio'];
            unset($_SESSION['envio']);
        }

        global $db;
        $cliente = $db->fetchRow($db->select()
                                ->from('ma_clientes', array('cli_nombre', 'cli_apellido', 'cli_id', 'cli_departamento', 'cli_pais',
                                    'cli_direccion', 'cli_distrito', 'cli_estado', 'cli_fecha_nac',
                                    'cli_telefono', 'cli_celular', 'cli_sexo'))
                                ->where('cli_id=?', $_SESSION['usr']['cli_id']));

        $pieces = explode("-", $cliente->cli_fecha_nac);
        $cliente->dia = $pieces[2];
        $cliente->mes = $pieces[1];
        $cliente->anio = $pieces[0];

        $smarty = new Smarty_Engine();
        $smarty->assign('cliente', $cliente);
        $smarty->assign('post', $post);
        $smarty->assign('error', $error);
        $smarty->assign('envio', $envio);

        return $smarty->fetch(APP_ROOT . DS . 'tpl' . DS . 'cuenta.tpl');
    }

}